<!--************************************************************ -->
<!--* 文件创建日期：2010                                  * -->
<!--* 文件修改日期：			                                   * -->
<!--************************************************************ -->
<!--JSP初始化设置-->
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="com.infomanage.po.*" %>
<%@page import="com.qs.po.*"%>
<%@page import="com.infomanage.vo.*" %>
<%@page import="com.qs.service.*"%>
<%@page import="com.infomanage.util.Consts"%>
<%  response.addDateHeader("Expires", 0);response.setHeader("Pragma","no-cache"); response.setHeader("Cache-Control","no-cache");%>
<%
	request.setCharacterEncoding("UTF-8");
	String itemId = request.getParameter("itemId");
	String type = request.getParameter("type");
    if(itemId == null) itemId = "";
    
    QsRecRuntime item = RecordRuntimeService.load(request, response, out);
    String filePath = "";
    String fileName = "";
    if(item != null){
    	fileName = item.getTitle();
     	filePath = request.getRealPath(Consts.FILE_UPLOAD_SAVE_DIR) + "/" + item.getAlias();
    }
%>
<html>
<head>
	<title><%if("".equals(itemId)){ %>文件上传<%}else{ %>信息修改<%} %></title>
	<META HTTP-EQUIV="Pragma" CONTENT="no-cache">	
	<link href="<%=request.getContextPath() %>/css/table.css" rel="stylesheet" type="text/css">
	<link href="<%=request.getContextPath() %>/css/calendar.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="<%=request.getContextPath() %>/js/calendar.js"></script>
	<script type="text/javascript">
	   function init() {
		   if("" != "<%=itemId%>") { // 修改
		   }
	   }
	   // 提交
	   function doSubmit(){
	   	   	if(!isvalidatefile()){
	   			return;
	   		}
		 	if("" == "<%=itemId%>") {
		 		form1.actionType.value = "add";
			}else {
		 		form1.actionType.value = "modifyInfo";
			}
		 	form1.submit();
	   }

	   function showError(error){
		   alert(error);
	   }

	   function showInfo(info){
		   alert(info);
		   window.returnValue = "ok";
		   window.close();
	   }
	   
	   function isvalidatefile(){
   		if(form1.title.value == ""){
   			alert("文件名称不能为空！");
   			return false;
   		}
   			   			   		
   		if(form1.title.value.length > 50){
			alert("名称不能超过50个字！");
			return false;
   	    }
   	    
	   	if("" == "<%=itemId%>") {//新增时验证文件类型   	    
			var extend = form1.file.value.substring(form1.file.value.lastIndexOf(".")+1);
			    if(extend==""){
			       alert("请上传后缀名为doc、docx或xls的文件!");
			       return false;
			    }else{
				if(!(extend=="doc"||extend=="docx" || extend=="xls")){
				   alert("请上传后缀名为doc或docx或xls的文件!");
				   return false;
				  }
			    }
		}
	    return true;
      }
	</script>
</head>
<body  rightmargin="0" bottommargin="0" leftmargin="0" topmargin="0"  onload="init();">
	<form name="form1" action="runtime_action.jsp" method="post" target="actionFrame" <%if("".equals(itemId)){ out.println("enctype='multipart/form-data'");}%>>
	<input type="hidden" name="itemId" value="<%=itemId%>">
	<input type="hidden" name="type" value="<%=type%>">
	<input type="hidden" name="actionType">
	<table class="dialogTable" cellpadding="0" cellspacing="0">
		<!-- 表头-->
		<tr class="dialogTableHeader">
			<td><%if("".equals(itemId)){ %>文件上传<%}else{ %>信息修改<%} %></td>
		</tr>
		<!-- 表数据-->
		<tr class="dialogTableContent">
			<td>
				<!-- 数据项 -->
				<table class="dataTable">
					<col width="30%">
					<col width="70%">
					<tr>
						<td class="field">
							标题
						</td>
						<td>
							<input name="title" style="width: 250px;" value="<%= fileName %>"/>
						</td>
					</tr>
					<% 
						if("".equals(itemId)){//新增
					%>							
					<tr>
						<td class="field">
							上传
						</td>
						<td>
							<input name="file" value="<%=filePath %>" type="file" style="width: 250px;"/>
						</td>
					</tr>
					<%
						}
					%>					
				</table>
			</td>
		</tr>
		<tr>
			<td colspan="2" class="tableBtn">
				<% 
					if(itemId == null || "".equals(itemId)){//新增
				%>	
					<span onclick="doSubmit();">上传</span>
				<%
					}else{
				%>
					<span onclick="doSubmit();">确定</span>
				<%
					}
				%>			
				<span onclick="window.close();">取消</span>
			</td>
		</tr>
		<tr valign="top">
			<td colspan="2">
				&nbsp;
			</td>
		</tr>
	</table>
	</form>
	<iframe src="#" name="actionFrame" style="display: none;"></iframe>
</body>
</html>